package de.fhhannover.inform.itteam.snmpnetviz.gui.renderer;

import javax.imageio.ImageIO;

import de.fhhannover.inform.itteam.snmpnetviz.gui.util.ScaleImage;

import prefuse.Constants;
import prefuse.render.ImageFactory;
import prefuse.render.LabelRenderer;

import java.awt.image.BufferedImage;
import java.io.IOException;

public class SnmpNetVizLabelRenderer extends LabelRenderer {
	public SnmpNetVizLabelRenderer(String value, String type) {
		super(value, type);
		BufferedImage switchIcon, hostIcon;
		try {
			switchIcon = ImageIO.read(this.getClass().getResource("/gfx/snmpNetViz/switch.png"));
			hostIcon = ImageIO.read(this.getClass().getResource("/gfx/snmpNetViz/host.png"));

			ImageFactory factory = new ImageFactory(50, 50);
			factory.addImage("switch", switchIcon);
			factory.addImage("host", ScaleImage.resizeImage(20, 20, hostIcon));
			
			this.setImageFactory(factory);
			this.setImagePosition(Constants.TOP);
			this.setMaxImageDimensions(50, 50);
			this.setImageTextPadding(0);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
